using System;
using System.Web.Mvc;
using Coleotrack.Controllers;
using Coleotrack.Data;
using Coleotrack.Service.Contracts;
using Moq;
using NUnit.Framework;

namespace Coleotrack.Test.Controllers
{
    public class IssueControllerTest : ConcernOf<IssueController>
    {
        private Mock<IIssueService> mockIssueService;

        public override void Setup()
        {
            mockIssueService = new Mock<IIssueService>();

            Sut = new IssueController(mockIssueService.Object);
            Sut.SetFakeControllerContext(false);
        }

        public override void Teardown()
        {
            //throw new NotImplementedException();
        }

        [Test]
        public void Index_should_return_view()
        {
            var result = Sut.List();

            Assert.IsInstanceOf(typeof(ViewResult), result);
        }

        [Test]
        public void Details_should_return_view()
        {
            mockIssueService.Setup(x => x.Find(1)).Returns(new Issue());

            var result = (ViewResult)Sut.Details(1);

            Assert.IsInstanceOf(typeof(ViewResult), result);
            Assert.IsNotNull(result.Model);
        }
    }
}